include config.mk

all: rr42xsu

build-all: rr42su rr42xsu
	
rr42su: src/rr42su.o src/librr42su.o src/suredirect.o
	$(CC) src/rr42su.o src/librr42su.o -o rr42su $(LDFLAGS)
	$(CC) src/suredirect.o -o suredirect $(LDFLAGS)
	
rr42xsu: src/rr42xsu.o src/librr42su.o
	$(CC) -o rr42xsu src/rr42xsu.o src/librr42su.o $(LDFLAGS)
	
install: install-rr42xsu

install-all: install-rr42su install-rr42xsu
	
install-rr42su:
	@echo installing rr42su...
	@echo prepairing folders...
	@mkdir -p $(BIN)
	@mkdir -p $(LIBEXEC)
	@echo installing executables to $(BIN)...
	@cp rr42su $(BIN)
	@cp suredirect $(LIBEXEC)

install-rr42xsu:
	@echo installing rr42xsu...
	@echo prepairing folders...
	@mkdir -p $(BIN)
	@echo installing executables to $(BIN)...
	@cp rr42xsu $(BIN)

	
uninstall: uninstall-all

uninstall-all:
	rm -f $(BIN)/rr42su
	rm -f $(BIN)/rr42xsu
	rm -f $(LIBEXEC)/suredirect
	mkdir -p $(LIBEXEC)
#FAIL/FIXME: rmdir fails if $(LIBEXEC) didn't exists, and it has option:
# "--ignore-fail-on-non-empty" which can delete not empty folder...
	rmdir $(LIBEXEC)

clean:
	rm -f *.o
	rm -f src/*.o
	rm -f rr42su
	rm -f rr42xsu
	rm -f suredirect
